//
//  BluetoothDeviceConfiger.h
//  BluetoothManager
//
//  Created by jinbo on 2025/8/27.
//

#import <Foundation/Foundation.h>
#import <BluetoothConfiger/WifiInfo.h>

NS_ASSUME_NONNULL_BEGIN
#define BTDeviceConfiger [BluetoothDeviceConfiger shareConfiger]

typedef NS_ENUM(NSInteger, BLEWifiState) {
    BLE_WIFI_STATE_NOCONFIG = 1,
    BLE_WIFI_STATE_CONFIG = 2,
    BLE_WIFI_STATE_CONNECTED = 3,
    BLE_WIFI_STATE_ERRORPASSWD = 10
};


@interface BluetoothInfo : NSObject
@property (nonatomic, strong) NSString *name;
@property (nonatomic, assign) BOOL connected;
@end

@protocol BluetoothDeviceConfigerDelegate <NSObject>
- (void)bluetoothDisconnect;
- (void)bluetoothPowerOff;
- (void)onWiFiStateChanged:(BLEWifiState)state;
@end

@interface BluetoothDeviceConfiger : NSObject
@property (nonatomic, weak) id<BluetoothDeviceConfigerDelegate> delegate;
@property (nonatomic, strong, readonly) NSArray <BluetoothInfo *> *devices;
@property (nonatomic, strong, readonly) BluetoothInfo * connectedDevice;

+ (instancetype)shareConfiger;

- (void)scanBluetoothWithKeyword:(NSString *)keyword deviceListCallback:(void(^)(NSArray<BluetoothInfo *> * list))callback;

- (void)stopScanBluetooth;

// 连接蓝牙设备
- (void)connectBluetoothWithDevice:(BluetoothInfo *)device
                        Completion:(void(^)(BOOL connectResult, NSError * _Nullable error))completionBlock;

// 断开已连接蓝牙设备
- (void)disConnectBlueDeviceWithCompletion:(void(^)(NSError * _Nullable error))completionBlock
                                    device:(BluetoothInfo *)device;

// 扫描wifi热点
- (void)scanApListWithCompletion:(void(^)(NSArray<WifiInfo *> *wifiInfos, NSError * _Nullable error))completionBlock;

// 连接配网wifi
- (void)connectWifi:(WifiInfo *)wifiInfo
         Completion:(void(^)(WifiInfo *wifiInfo, int errorCode, int wifiState))completionBlock;

// 获取设备WiFi状态
-(void)acceptWifiStatusWithCompletion:(void(^)(int wifiState,NSError * _Nullable error))completionBlock;
    
    // 获取设备SSID
    - (void)acceptDeviceSSIDWithCompletion:(void(^)(NSString * _Nullable ssid, NSError * _Nullable error))completionBlock;
@end

NS_ASSUME_NONNULL_END
